﻿//jquery.js
//jquery.colorbox.js

(function ($) {

    $.nhColorboxDefaultOptions = {
        close: '',
        transition: 'elastic',
        open: true,
        width: 'auto',
        height: 'auto',
        speed: 350,
        opacity: 0.70,
        title: false,
        fixed: true,
        href: '#',
        xhrError: "An unexpected error occurred. Please refresh and try again.",

        onClosed: function () {
            $.colorbox.element().remove();
        }
    };

    var methods = {
        init: function (options) {
            var self = this;

            // Get the defaults and override with options
            self.options = options = $.extend({}, $.nhColorboxDefaultOptions, options);
            $.colorbox(self.options);
        }
    };

    $.nhColorbox = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.nhColorbox');
        }
    };

    $.nhColorbox.resize = function () {
        $.colorbox.resize();
    };

    $.nhColorbox.close = function () {
        $.colorbox.close();
        $.colorbox.element().remove();
    };

})(jQuery);